﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;

namespace Graphing.ViewModel
{
    class FormulaViewModel : ViewModelBase
    {
        #region Fields

        private string _expression;
        private ICommand _formulaButtonCommand;

        #endregion // Fields.

        #region Properties

        // Expression from the Formula View.
        public String Expression
        {
            get
            {
                return _expression;
            }
            set
            {
                if (_expression != value)
                    _expression = value;

                base.OnPropertyChanged("_expression");
            }
        }

        #endregion // Properties.

        #region Commands


        // Command to Update the Expression when a Button is clicked.
        public ICommand FormulaButtonCommand
        {
            get
            {
                if (_formulaButtonCommand == null)
                {
                    _formulaButtonCommand = new DelegateCommand<string>(editExpression);
                }
                return _formulaButtonCommand;
            }
        }

        #endregion // Commands.

        #region UpdateExpression

        public void editExpression(string input)
        {
            _expression += input;

            base.OnPropertyChanged("Expression");
        }
        #endregion // UpdateExpression.

    }
}
